<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="dv111">21412414</div>
    <input type="button" value="" onclick="test()">
    <script>
        // 设置标签文本内容textContent 谷歌 火狐支持 ie8 不支持
        // 设置标签文本内容tinnerText 谷歌 火狐 ie8 全部支持


    // 兼容浏览器设置标签内容   
    function setHtmlText(elemnt,text){
        //不兼容 使用innerText方式
        if(typeof elemnt.textContent == "undefined") {
            elemnt.innerText = text;    
        } else {
            //兼容
            elemnt.textContent = text; 
        }
    }

    //兼容浏览器设获取标签内容
    function getHtmlText(elemnt) {
        //不兼容 使用innerText方式
        if(typeof elemnt.textContent == "undefined") {
           return elemnt.innerText;    
        } else {
            //兼容
            return elemnt.textContent; 
        }
    }

    function test(){
        var divObjet = document.getElementById("dv111");
         alert(getHtmlText(divObjet))
         setHtmlText(divObjet,"22222");
         alert(getHtmlText(divObjet))
    }

    
    </script>
</body>
</html>